package chapter2.eg5;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.AsynchronousSocketChannel;
import java.util.concurrent.CountDownLatch;
import org.junit.Test;

public class EchoClient {
  @Test
  public void testClient() throws IOException, InterruptedException {
    CountDownLatch latch = new CountDownLatch(1);
    AsynchronousSocketChannel socketChannel = AsynchronousSocketChannel.open();
    socketChannel.connect(new InetSocketAddress("127.0.0.1", 8080), socketChannel, new ConnectCompletionHandler(latch));
    latch.await();
  }

}
